<?php
namespace backend\components\helper;

use yii\helpers\Url;
use yii\helpers\BaseHtml;

class EasyHtml extends BaseHtml
{
    /**
     * iconLink
     * @param $text
     * @param null $url
     * @param array $options
     * @return string
     */
    public static function iconLink($text, $url = null, $options = [])
    {
        if ($url !== null) {
            $options['href'] = Url::to($url);
        }

        $options['icon'] = $options['icon']??'circle-o';

        $iconOptions['class'] = 'fa fa-'.$options['icon'];

        unset($options['icon']);

        $text = self::tag('i','',$iconOptions).' '.$text;

        return static::tag('a', $text, $options);
    }

    /**
     * iconSubmitButton
     * @param string $content
     * @param array $options
     * @return string
     */
    public static function iconSubmitButton($content = 'Submit', $options = [])
    {
        $iconOptions['class'] = 'fa fa-'.($options['icon']??'save');

        $content = self::tag('i','',$iconOptions).' '.$content;

        return self::submitButton($content, $options);
    }
}
